import utils from './utils.js';
	
	function setSID(){
		let SID = new Date().getTime()+utils.ramdom(1,1000);
		return SID
	}
	export default {
	setListData: function(billtype, status,queryByTime,ischeck) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"billtype": billtype,
			"TYPE": "3",
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "index_query",
				"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
				"state": status ? status : '2',
				"ischeck":ischeck,
			}
		}
		if (queryByTime != null) {
			data.DATA.sdate = queryByTime.startTime
			data.DATA.edate = queryByTime.endTime
		}
		return data
	}, //设置请求审核列表各项的数据。
	setLeaveListData: function(billtype,ischeck,head,state) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"billtype": billtype,
			"TYPE": "3",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "index_query",
				"pk_period_b":head.pk_period_b,
				"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
				"ischeck":ischeck,
				"pk_leavetype":head.pk_leavetype,
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
				"state":state?state:"2"
			}
		}
		return data
	}, //设置请求请假审核列表各项的数据。
	setQuitListData: function(billtype,ischeck) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"billtype": billtype,
			"TYPE": "3",
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "index_query",
				"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
				"ischeck":ischeck,
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
				"state":"2"
			}
		}
		return data
	}, //设置请求请假审核列表各项的数据。
	setAtedanceList: function(billtype,ischeck,opt,status) {
		let data = {
			"SID":setSID(),
			"KEY":"wdhl",
			"billtype":billtype,
			"TYPE":"3",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS":"企业微信",
			"DATA":{
				"action":"index_query",
				"pk_team":opt.pk_team?opt.pk_team:'',
				"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
				"pk_period_b":opt.pk_period_b?opt.pk_period_b:'',
				"ischeck":ischeck?ischeck:'N',
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
				"state":status ? status : '2'
				}
			}
		
		return data
	}, //设置请求审核列表各项的数据。
	setSalaryList: function(billtype,ischeck,date,status) {
		let data = {
			"SID":setSID(),
			"KEY":"wdhl",
			"billtype":billtype,
			"TYPE":"3",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS":"企业微信",
			"DATA":{
					"action":"index_query",
					"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
					"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
					"ischeck":ischeck?ischeck:'N',
					"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
					"state":status ? status : '2',
					"year":date.year,
					"month":date.month
				}
					}
		
		return data
	}, //设置请求审核列表各项的数据。
	getWorkGroup:function(refertype) {
		let data = {
				"SID": setSID(),
				"KEY": "wdhl",
				"TYPE": 8,
				"SRCSYS": "企业微信",
				"DATA": [
					{
						"refertype":refertype
					   
					}
				],
				"VERIFY":JSON.parse(uni.getStorageSync('user')).token
			}
					
		return data
	}, //设置请求审核列表各项的数据。
	setExamineData: function(billtype, isAdopt, pk,opinion) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"TYPE": "3",
			"billtype": billtype,
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "approve",
				"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
				"approve": isAdopt ? "Y" : 'R',
				"pk": pk,
				"opinion":opinion,
				"pk_group": JSON.parse(uni.getStorageSync('user')).pk_group
			},
		}
		
		return data
	}, //设置请求审核通过数据。
	salaryExamineData: function(billtype, isAdopt, pk,opinion,rgman_pks) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"TYPE": "3",
			"billtype": billtype,
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "approve",
				"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
				"approve": isAdopt ? "Y" : 'R',
				"pk": pk,
				"iszp":"Y",//n 返回查询列表 y提交
				"sprs":[...rgman_pks],
				"opinion":opinion,
				"pk_group": JSON.parse(uni.getStorageSync('user')).pk_group
			},
		}
		return data
	}, //设置请求审核通过数据。
	setUserCodeData: function(code,app_code) { 
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"TYPE": "2",
			"VERIFY": "7ac66c0f148de9519b8bd264312c4d64",
			"SRCSYS": "企业微信",
			"DATA": [{
				// "user_code": code,
				"app_code":app_code,
					"code":code
			}]
		}
		return data
	}, //设置获取userCode的data
	setPrograssData: function(pk,billtype) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"billtype": billtype,
			"TYPE": "3",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "return_approve",
				"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk": pk,
				"billtype": billtype,
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
			}
		}
		return data
	}, //设置获取userCode的data
	setExitExamineData: function(pk,billtype) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"billtype": billtype,
			"TYPE": "3",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action":"unapprove",
				"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk": pk,
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
			}
		}
		return data
	}, //设置获取userCode的data
	destroyLeave:function(data,billno){
		let nowTime = utils.getNowTime()
		let apidata = {
			"SID": setSID(),
			"KEY": "wdhl",
			"TYPE": "3",
			"billtype": "HA02",
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
				"action": "add",
				"head": {
					"abledays": 0,
					"applydate": data.applydate,
					"approvedate": null,
					"approvenote": null,
					"approver": null,
					"approvestatus":data.approvestatus,
					"begintime": null,
					"billmaker": JSON.parse(uni.getStorageSync('user')).cuserid,
					"billno": billno?billno:null,
					"billtype": "HA02",
					"billversionpk": null,
					"busitype": null,
					"code": null,
					"creationtime": null,
					"creator": null,
					"dbilldate": utils.getNowTime(),
					"def1": null,
					"def10": null,
					"def2": null,
					"def3": null,
					"def4": null,
					"def5": null,
					"def6": null,
					"def7": null,
					"def8": null,
					"def9": null,
					"differencehour": null,
					"dr": 0,
					"emendenum": null,
					"endtime": null,
					"lastmaketime": null,
					"leavebeginpro":data.leavebeginpro,
					"leavedays": data.leavedays,
					"leaveendpro":data.leaveendpro,
					"leaveoffshift": data.leaveoffshift,
					"leaveshiftpro":data.leaveshiftpro,
					"leaveyear": new Date(utils.getDateDiff(nowTime)).getFullYear(),
					"maketime": null,
					"modifiedtime": null,
					"modifier": null,
					"name": null,
					"pk_group": JSON.parse(uni.getStorageSync('user')).pk_group,
					"pk_item": null,
					"pk_leaveoff":data.pk_leaveoff?data.pk_leaveoff:null,
					"pk_leavetype":data.pk_leavetype,
					"pk_org": JSON.parse(uni.getStorageSync('user')).pk_org,
					"pk_org_v": null,
					"pk_period": data.pk_period,
					"pk_psndoc": JSON.parse(uni.getStorageSync('user')).pk_psndoc,
					"pk_psnjob":JSON.parse(uni.getStorageSync('user')). pk_psnjob,
					"pseudocolumn": null,
					"realbegintime": data.realbegintime,
					"realendtime":data.realendtime,
					"realleavedays":data.realleavedays,
					"restedday":data.restedday,
					"srcbillid": null,
					"srcbilltype": null,
					"transtype": null,
					"transtypepk": null,
					"ts": data.ts
				},
				"bodys": [],
			}
		}
		return apidata
	},
	getLeaveTypeData: function(type,pk_leavetype) {
		let data = {
			"SID": setSID(),
			"KEY": "wdhl",
			"TYPE": 8,
			"SRCSYS": "企业微信",
			"DATA": [{
				"refertype": type,
			}],
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token
		}
		if(type =="leaveshift"&&pk_leavetype!=1){
			data.DATA[0].where="pk_leavetype="+"\'"+pk_leavetype+"\'"
		}
		return data
	}, //设置获取userCode的data
	changeLeaveData:function(head,formData){
		let nowTime = utils.getNowTime()
	  let data = {
		  "SID":setSID(),
		  "KEY":"wdhl",
		  "TYPE":"3",
		  "billtype":"HA01",
		 "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
		  "SRCSYS":"企业微信",
		  "DATA":{
		      "action":"add",
		      "head":{
		          "pk_leave_h": head.pk_leave_h,
					"applydate":nowTime,
					"approvestatus":"-1",
		          "billmaker":head.billmaker,
		          "billtype":"HA01",
		          "creationtime":nowTime,
		          "creator":head.creator,
		         "dbilldate":nowTime, 
		          "dr":"0",
				  "leaveyear":new Date(utils.getDateDiff(nowTime)).getFullYear(),
		         "lastmaketime":nowTime,
		         "maketime":nowTime,
		         "pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
		         "pk_leavetype":head.pk_leavetype,
		         "pk_org":JSON.parse(uni.getStorageSync('user')).pk_org,
		          "pk_org_v":head.pk_org_v,
				"pk_period":head.pk_period,
		         "pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
		         "pk_psnjob":JSON.parse(uni.getStorageSync('user')). pk_psnjob,
		          "ts":head.ts,
		          "billno": head.billno,
				  "vdef2":head.vdef2,//
				  "vdef3":head.vdef3,//
		      },
		      "bodys":Array.isArray(formData)?[...formData]:[formData]
		  }
	  }
	  return data
	},
	getFileList:function(pk){
		let data={
			"SID":setSID(),
			"KEY":"wdhl",
			"TYPE":"11",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS":"企业微信",
			"DATA":[
				{
					"pk":pk
				}
			]
			}
		return data
	},
	deleteFile:function(pk){
		let data ={
				"SID":setSID(),
				"KEY":"wdhl",
				"TYPE":"13",
				"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
				"SRCSYS":"企业微信",
				"DATA":
					{
						"pk_doc":pk
					}
				
			}
			return data
	},
	setLeaveData: function(head, formData) {
		let nowTime = utils.getNowTime()
		let data = {
    "SID":setSID(),
    "KEY":"wdhl",
    "TYPE":"3",
    "billtype":"HA01",
    "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
    "SRCSYS":"企业微信",
    "DATA":{
        "action":"add",
        "head":{
            "applydate":nowTime,
            "approvestatus":"-1",
           "applydate":nowTime,
           "approvestatus":"-1",
            "creationtime":nowTime,
            "creator":JSON.parse(uni.getStorageSync('user')).cuserid,
            "dbilldate":nowTime, 
			"billmaker":JSON.parse(uni.getStorageSync('user')).cuserid,
            "dr":"0",
			"leaveyear":head.leaveyear,
            "lastmaketime":nowTime,
			"maketime":nowTime,
            "pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
            "pk_leavetype":head.pk_leavetype,
            "pk_org":JSON.parse(uni.getStorageSync('user')).pk_org,
			 "pk_org_v":"0001A110000000002YNB",
            "pk_period":head.pk_period,
            "pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
            "pk_psnjob":JSON.parse(uni.getStorageSync('user')). pk_psnjob,
			"vdef2":head.vdef2,//
			"vdef3":head.vdef3,//

        }, 
		"bodys":Array.isArray(formData)?[...formData]:[formData]
    }
}
		return data
	},
	setLeaveData: function(head, formData) {
			let nowTime = utils.getNowTime()
			let data = {
	    "SID":setSID(),
	    "KEY":"wdhl",
	    "TYPE":"3",
	    "billtype":"HA01",
	    "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
	    "SRCSYS":"企业微信",
	    "DATA":{
	        "action":"add",
	        "head":{
	            "applydate":nowTime,
	            "approvestatus":"-1",
	           "applydate":nowTime,
	           "approvestatus":"-1",
	            "creationtime":nowTime,
	            "creator":JSON.parse(uni.getStorageSync('user')).cuserid,
	            "dbilldate":nowTime, 
				"billmaker":JSON.parse(uni.getStorageSync('user')).cuserid,
	            "dr":"0",
				"leaveyear":head.leaveyear,
	            "lastmaketime":nowTime,
				"maketime":nowTime,
	            "pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
	            "pk_leavetype":head.pk_leavetype,
	            "pk_org":JSON.parse(uni.getStorageSync('user')).pk_org,
				 "pk_org_v":"0001A110000000002YNB",
	            "pk_period":head.pk_period,
	            "pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
	            "pk_psnjob":JSON.parse(uni.getStorageSync('user')). pk_psnjob,
				"vdef2":head.vdef2,//
				"vdef3":head.vdef3,//
	        }, 
			"bodys":Array.isArray(formData)?[...formData]:[formData]
	    }
	}
			return data
		},
	
	delLeaveRecord:function(pk,billtype){
		let data ={
			 "SID": setSID(),
			 "KEY": "wdhl",
			 "TYPE": "3",
			 "billtype": billtype,
			 "VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			 "SRCSYS": "企业微信",
			 "DATA": {
			  "action": "delete",
			  "cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
			  "pk": pk,
			  "pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
			 }
			}
		return data
	},
	takebackRecord:function(pk,billtype){
		let data ={
			 "SID": setSID(),
			 "KEY": "wdhl",
			 "TYPE": "3",
			 "billtype": billtype,
			 "VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			 "SRCSYS": "企业微信",
			 "DATA": {
			  "action": "unsave",
			  "cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
			  "pk": pk,
			  "pk_group":JSON.parse(uni.getStorageSync('user')).pk_group,
			 }
			}
		return data
	},
	setSalayList:function(date){
		let data ={
			"SID":setSID(),
			"KEY":"wdhl",
			"TYPE":"12",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS":"企业微信",
			"DATA":[
				{
					"querytypecode":"wx_05",
					"filters":{
						"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
						"periods":date,
					},
				}
			]
		}
		return data
	},
	getMyInform: function(pk_doc) {
		let data ={
			"SID":setSID(),
			"KEY":"wdhl",
			"TYPE":"12",
			"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS":"企业微信",
			"DATA":[
				{
					"querytypecode":"wx_04",
					"filters":{"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc},
					"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
					"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group
				}
			]
		}
		return data
	},//获取个人信息
	getHasLeave: function(head) {
		let data ={
				"SID": setSID(),
			    "KEY": "wdhl",
			    "TYPE": 3,
			    "billtype":"HA01",
			    "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			    "SRCSYS": "企业微信",
			    "DATA": 
			        {
			            "action": "query",
			            "pk_org":JSON.parse(uni.getStorageSync('user')).pk_org,
			            "timeyear":head.timeyear,
			            "pk_leavetype":head.leavetype,
			            "pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
			            "pk_period":head.pk_period
			        }
		}
		return data
	},//获取假期天数
	getUsers:function(){
		let data ={
				"SID": setSID(),
			    "KEY": "wdhl",
			    "TYPE": 3,
			    "billtype":"HA01",
			    "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			    "SRCSYS": "企业微信",
			    "DATA": 
			        {
			            "action": "query_user",
						"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
			        }
		}
		return data
	},
	assign(form_pk,rgman_pks,billtype,action,iszp){
		let data ={
				  "SID": setSID(),
				  "KEY": "wdhl",
				  "TYPE": "3",
				  "billtype": billtype,
				  "VERIFY": JSON.parse(uni.getStorageSync('user')).token,
				  "SRCSYS": "企业微信",
				  "DATA": {
				    "action": action,
				    "cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
					"iszp":iszp,//n 返回查询列表 y提交
				    "approve": "Y",
					"opinion":"",
				    "pk": form_pk,
				    "sprs":[...rgman_pks],
				    "pk_group": JSON.parse(uni.getStorageSync('user')).pk_group
				  }
				}
		return data
	},//指派操作
	getLeaveRecord:function(billtype,st,et,){
		let data =
			{"SID":setSID(),
				"KEY":"wdhl",
				"billtype":billtype,
				"TYPE":"3",
				"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
				"SRCSYS":"企业微信",
				"DATA":{
					"action":"index_query",
					"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
					"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
					"state":"0",
					"sdate":st,
					"edate":et,
					}
				}
		return data
	},
	getQuitRecord:function(st,et){
		let data =
			{"SID":setSID(),
				"KEY":"wdhl",
				"billtype":"6115",
				"TYPE":"3",
				"VERIFY":JSON.parse(uni.getStorageSync('user')).token,
				"SRCSYS":"企业微信",
				"DATA":{
					"action":"index_query",
					"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
					"state":"0",
					"sdate":st,
					"edate":et,
					}
				}
		return data
	},
	setWorkPeriodData(){
		let data =
			{
			    "SID": setSID(),
			    "KEY": "wdhl",
			    "TYPE": 8,
			    "SRCSYS": "企业微信",
			    "DATA": [
			        {
			            "refertype": "kqqj",
			           
			        }
			    ],
			    "VERIFY": JSON.parse(uni.getStorageSync('user')).token
			}
		return data
	},
	setQuitReason(){
		let data =
			{
			    "SID":setSID(),
			    "KEY": "wdhl",
			    "TYPE": 8,
			    "SRCSYS": "企业微信",
			    "DATA": [
			        {
			            "refertype": "ydyy",
			           
			        }
			    ],
			    "VERIFY": JSON.parse(uni.getStorageSync('user')).token
			}
		return data
	},
	setQuitData(head){
		let data ={
			    "SID":setSID(),
			    "KEY":"wdhl",
			    "TYPE":"3",
			    "billtype":"6115",
			    "VERIFY":JSON.parse(uni.getStorageSync('user')).token,
			    "SRCSYS":"企业微信",
			    "DATA":{
			        "action":"add",
			        "head": {
							"pk_psndoc":JSON.parse(uni.getStorageSync('user')).pk_psndoc,
			                "apply_date ": head.apply_date,//"2021-07-18"
			                "pk_group": JSON.parse(uni.getStorageSync('user')).pk_group,
			                "pk_org": JSON.parse(uni.getStorageSync('user')).pk_org,
			                "billmaker":JSON.parse(uni.getStorageSync('user')).cuserid,
			                "pk_psnjob":JSON.parse(uni.getStorageSync('user')). pk_psnjob,
			                "pk_trnstype": "1002Z710000000008GSW",
			                "sreason": head.sreason,//("1001A11000000003AM6A")
			                "effectdate":  head.apply_date,
			                "pk_psnorg":JSON.parse(uni.getStorageSync('user')).pk_org,
			                "memo": head.memo,
			                "pk_old_hi_org": JSON.parse(uni.getStorageSync('user')).pk_org
			            },
				"cuserid":JSON.parse(uni.getStorageSync('user')).cuserid,
				"pk_group":JSON.parse(uni.getStorageSync('user')).pk_group
			    }
			}
		return data
	},
	/**********************绩效************************/
	getMerits(){
		let data ={
			"SID": 1641375482621,
			"KEY": "wdhl",
			"billtype": "WAMP",
			"TYPE": "3",
			"VERIFY": JSON.parse(uni.getStorageSync('user')).token,
			"SRCSYS": "企业微信",
			"DATA": {
			"action": "index_query",
			"pk_period_b": "",
			"cuserid": JSON.parse(uni.getStorageSync('user')).cuserid,
			"pk_psndoc": JSON.parse(uni.getStorageSync('user')). pk_psnjob,
			"ischeck": isCheck,
			"pk_leavetype": "",
			"pk_group": JSON.parse(uni.getStorageSync('user')).pk_group,
			"state": "0"
			}
		}
		return data
	}
	
}
